在单发样本中找到有差异的(BF>1)且具有相同pattern的位点，生物学重复2个的位点有244个，3个生物学重复的有8个。
setwd("E:\\5hmc_file\\2_5hmc_yjp_bam\\ASM\\bayes_pvalue_beta0")
file=read.table("pvalue_sig_statis.csv",head=T,sep=",")
sel=which(file$num1==2&file$twins==1)
file=file[!(file$num1==2&file$twins==1),]
file=file[file$num1>1,]
id=file$unitID

setwd("E:\\5hmc_file\\2_5hmc_yjp_bam\\ASM")
dir1="./bayes_pvalue_beta0/"
dir2="./bayes_BF/"
group1=c("X2B_X1T","M8_M7","M6_M5","M2_M1","M48_M47","M50_M49","M28_M27","M30_M29","M26_M25","M35_M36","M18_M17","M20_M19","M22_M21","M40_M39")
i=1
  fn1=paste0(dir1,group1[i],".bayes_p.txt")
  file1=read.table(fn1,head=T,sep = "\t")
  file1$unitID=paste(file1$chrom,file1$position,file1$ref,file1$var,sep=":")
  file1=data.frame(unitID=file1$unitID,normal_bayes_beta0=file1$normal_bayes_beta0,normal_bayes_pvalue=file1$normal_bayes_pvalue,tumor_bayes_beta0=file1$tumor_bayes_beta0,tumor_bayes_pvalue=file1$tumor_bayes_pvalue)
  file1$FDR1=p.adjust(file1$normal_bayes_pvalue,method = "BH")
  file1$FDR2=p.adjust(file1$tumor_bayes_pvalue,method = "BH")
  
  fn2=paste0(dir2,group1[i],".bayes_factor.txt")
  file2=read.table(fn2,head=T,sep="\t")
  file2$unitID=paste(file2$chrom,file2$position,file2$ref,file2$var,sep=":")
  file2=data.frame(unitID=file2$unitID,BayesFactor=file2$BayesFactor)
  file=merge(file2,file1,by="unitID")
  file=file[file$FDR1<0.1|file$FDR2<0.1,]
file=file[file$BayesFactor>1,]
file$normal_group="nosig"
  file[file$normal_bayes_beta0>0&file$FDR1<0.1,]$normal_group="up"
  file[file$normal_bayes_beta0<0&file$FDR1<0.1,]$normal_group="down"
  file$tumor_group="nosig"
  file[file$tumor_bayes_beta0>0&file$FDR2<0.1,]$tumor_group="up"
  file[file$tumor_bayes_beta0<0&file$FDR2<0.1,]$tumor_group="down"
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file=file[,-c(4,6,9,10)]
names(file)=c("unitID",paste(group1[i],names(file)[2:6],sep="_"),names(file)[7])
rt1=data.frame(table(file$pattern))
names(rt1)=c("Var1",group1[i])

normal_up_tumor_nosig=file[file$pattern=="normal_up-tumor_nosig",][,1:6]
normal_up_tumor_up=file[file$pattern=="normal_up-tumor_up",][,1:6]
normal_down_tumor_nosig=file[file$pattern=="normal_down-tumor_nosig",][,1:6]
normal_nosig_tumor_up=file[file$pattern=="normal_nosig-tumor_up",][,1:6]
normal_down_tumor_up=file[file$pattern=="normal_down-tumor_up",][,1:6]
normal_up_tumor_down=file[file$pattern=="normal_up-tumor_down",][,1:6]
normal_down_tumor_down=file[file$pattern=="normal_down-tumor_down",][,1:6]
normal_nosig_tumor_down=file[file$pattern=="normal_nosig-tumor_down",][,1:6]
for (i in 2:6) {
 fn1=paste0(dir1,group1[i],".bayes_p.txt")
  file1=read.table(fn1,head=T,sep = "\t")
  file1$unitID=paste(file1$chrom,file1$position,file1$ref,file1$var,sep=":")
  file1=data.frame(unitID=file1$unitID,normal_bayes_beta0=file1$normal_bayes_beta0,normal_bayes_pvalue=file1$normal_bayes_pvalue,tumor_bayes_beta0=file1$tumor_bayes_beta0,tumor_bayes_pvalue=file1$tumor_bayes_pvalue)
  file1$FDR1=p.adjust(file1$normal_bayes_pvalue,method = "BH")
  file1$FDR2=p.adjust(file1$tumor_bayes_pvalue,method = "BH")
  
  fn2=paste0(dir2,group1[i],".bayes_factor.txt")
  file2=read.table(fn2,head=T,sep="\t")
  file2$unitID=paste(file2$chrom,file2$position,file2$ref,file2$var,sep=":")
  file2=data.frame(unitID=file2$unitID,BayesFactor=file2$BayesFactor)
  file=merge(file2,file1,by="unitID")
  file=file[file$FDR1<0.1|file$FDR2<0.1,]
file=file[file$BayesFactor>1,]
file$normal_group="nosig"
  file[file$normal_bayes_beta0>0&file$FDR1<0.1,]$normal_group="up"
  file[file$normal_bayes_beta0<0&file$FDR1<0.1,]$normal_group="down"
  file$tumor_group="nosig"
  file[file$tumor_bayes_beta0>0&file$FDR2<0.1,]$tumor_group="up"
  file[file$tumor_bayes_beta0<0&file$FDR2<0.1,]$tumor_group="down"
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file=file[,-c(4,6,9,10)]
names(file)=c("unitID",paste(group1[i],names(file)[2:6],sep="_"),names(file)[7])
test=data.frame(table(file$pattern))
names(test)=c("Var1",group1[i])
rt1=merge(rt1,test,by="Var1")
normal_up_tumor_nosig=merge(normal_up_tumor_nosig,file[file$pattern=="normal_up-tumor_nosig",][,1:6],by="unitID",all=T)
  normal_up_tumor_up=merge(normal_up_tumor_up,file[file$pattern=="normal_up-tumor_up",][,1:6],by="unitID",all=T)
  normal_down_tumor_nosig=merge(normal_down_tumor_nosig,file[file$pattern=="normal_down-tumor_nosig",][,1:6],by="unitID",all=T)
  normal_nosig_tumor_up=merge(normal_nosig_tumor_up,file[file$pattern=="normal_nosig-tumor_up",][,1:6],by="unitID",all=T)
  normal_down_tumor_up=merge(normal_down_tumor_up,file[file$pattern=="normal_down-tumor_up",][,1:6],by="unitID",all=T)
  normal_up_tumor_down=merge(normal_up_tumor_down,file[file$pattern=="normal_up-tumor_down",][,1:6],by="unitID",all=T)
  normal_down_tumor_down=merge(normal_down_tumor_down,file[file$pattern=="normal_down-tumor_down",][,1:6],by="unitID",all=T)
  normal_nosig_tumor_down=merge(normal_nosig_tumor_down,file[file$pattern=="normal_nosig-tumor_down",][,1:6],by="unitID",all=T)
}
normal_up_tumor_nosig$pattern="normal_up-tumor_nosig"
normal_up_tumor_up$pattern="normal_up-tumor_up"
normal_down_tumor_nosig$pattern="normal_down-tumor_nosig"
normal_nosig_tumor_up$pattern="normal_nosig-tumor_up"
normal_down_tumor_up$pattern="normal_down-tumor_up"
normal_up_tumor_down$pattern="normal_up-tumor_down"
normal_down_tumor_down$pattern="normal_down-tumor_down"
normal_nosig_tumor_down$pattern="normal_nosig-tumor_down"
rt=rbind(normal_up_tumor_nosig,normal_up_tumor_up,normal_down_tumor_nosig,normal_nosig_tumor_up,normal_down_tumor_up,normal_up_tumor_down,normal_down_tumor_down,normal_nosig_tumor_down)

rt$num=rowSums(rt[,grep(names(rt),pattern = "BayesFactor")]>0,na.rm = TRUE)#算有差异的位点的生物学重复次数
test=rt[rt$num>1,]
write.csv(test,"./20201110找到有差异的且具有相同pattern的位点/BF1.repeat.more.than.2.csv",quote=F,row.names=F)

rt2=rt1
rt2[2,8:15]=rt2[2,8:15]+rt2[4,8:15]
rt2[4,8:15]=rep(NA,8)
rt2[3,8:15]=rt2[3,8:15]+rt2[6,8:15]
rt2[6,8:15]=rep(NA,8)
rt2[5,8:15]=rt2[5,8:15]+rt2[7,8:15]
rt2[7,8:15]=rep(NA,8)
write.csv(rt2,"./20201110找到有差异的且具有相同pattern的位点/BF.1.statis.csv",quote=F,row.names=F)

###统计信息
###统计信息表
i=1
fn1=paste0(dir1,group1[i],".bayes_p.txt")
  file1=read.table(fn1,head=T,sep = "\t")
  file1$unitID=paste(file1$chrom,file1$position,file1$ref,file1$var,sep=":")
  file1=data.frame(unitID=file1$unitID,normal_bayes_beta0=file1$normal_bayes_beta0,normal_bayes_pvalue=file1$normal_bayes_pvalue,tumor_bayes_beta0=file1$tumor_bayes_beta0,tumor_bayes_pvalue=file1$tumor_bayes_pvalue)
  file1$FDR1=p.adjust(file1$normal_bayes_pvalue,method = "BH")
  file1$FDR2=p.adjust(file1$tumor_bayes_pvalue,method = "BH")
  
  fn2=paste0(dir2,group1[i],".bayes_factor.txt")
  file2=read.table(fn2,head=T,sep="\t")
  file2$unitID=paste(file2$chrom,file2$position,file2$ref,file2$var,sep=":")
  file2=data.frame(unitID=file2$unitID,BayesFactor=file2$BayesFactor)
  file=merge(file2,file1,by="unitID")
  file=file[file$FDR1<0.1|file$FDR2<0.1,]
file=file[file$BayesFactor>1,]
file$normal_group="nosig"
  file[file$normal_bayes_beta0>0&file$FDR1<0.1,]$normal_group="up"
  file[file$normal_bayes_beta0<0&file$FDR1<0.1,]$normal_group="down"
  file$tumor_group="nosig"
  file[file$tumor_bayes_beta0>0&file$FDR2<0.1,]$tumor_group="up"
  file[file$tumor_bayes_beta0<0&file$FDR2<0.1,]$tumor_group="down"
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file=file[,-c(4,6,9,10)]
names(file)=c("unitID",paste(group1[i],names(file)[2:6],sep="_"),names(file)[7])
rt1=data.frame(table(file$pattern))
names(rt1)=c("Var1",group1[i])

for(i in 2:14){
fn1=paste0(dir1,group1[i],".bayes_p.txt")
  file1=read.table(fn1,head=T,sep = "\t")
  file1$unitID=paste(file1$chrom,file1$position,file1$ref,file1$var,sep=":")
  file1=data.frame(unitID=file1$unitID,normal_bayes_beta0=file1$normal_bayes_beta0,normal_bayes_pvalue=file1$normal_bayes_pvalue,tumor_bayes_beta0=file1$tumor_bayes_beta0,tumor_bayes_pvalue=file1$tumor_bayes_pvalue)
  file1$FDR1=p.adjust(file1$normal_bayes_pvalue,method = "BH")
  file1$FDR2=p.adjust(file1$tumor_bayes_pvalue,method = "BH")
  
  fn2=paste0(dir2,group1[i],".bayes_factor.txt")
  file2=read.table(fn2,head=T,sep="\t")
  file2$unitID=paste(file2$chrom,file2$position,file2$ref,file2$var,sep=":")
  file2=data.frame(unitID=file2$unitID,BayesFactor=file2$BayesFactor)
  file=merge(file2,file1,by="unitID")
  file=file[file$FDR1<0.1|file$FDR2<0.1,]
file=file[file$BayesFactor>1,]
file$normal_group="nosig"
  file[file$normal_bayes_beta0>0&file$FDR1<0.1,]$normal_group="up"
  file[file$normal_bayes_beta0<0&file$FDR1<0.1,]$normal_group="down"
  file$tumor_group="nosig"
  file[file$tumor_bayes_beta0>0&file$FDR2<0.1,]$tumor_group="up"
  file[file$tumor_bayes_beta0<0&file$FDR2<0.1,]$tumor_group="down"
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file=file[,-c(4,6,9,10)]
names(file)=c("unitID",paste(group1[i],names(file)[2:6],sep="_"),names(file)[7])
test=data.frame(table(file$pattern))
names(test)=c("Var1",group1[i])
rt1=merge(rt1,test,by="Var1")
}
rt2=rt1
rt2[2,8:15]=rt2[2,8:15]+rt2[4,8:15]
rt2[4,8:15]=rep(NA,8)
rt2[3,8:15]=rt2[3,8:15]+rt2[6,8:15]
rt2[6,8:15]=rep(NA,8)
rt2[5,8:15]=rt2[5,8:15]+rt2[7,8:15]
rt2[7,8:15]=rep(NA,8)
write.csv(rt2,"./20201110找到有差异的且具有相同pattern的位点/FDR.0.1.sig.statis.csv",quote=F,row.names=F)

###分病种统计
###单发
i=1
fn1=paste0(dir1,group1[i],".bayes_p.txt")
  file1=read.table(fn1,head=T,sep = "\t")
  file1$unitID=paste(file1$chrom,file1$position,file1$ref,file1$var,sep=":")
  file1=data.frame(unitID=file1$unitID,normal_bayes_beta0=file1$normal_bayes_beta0,normal_bayes_pvalue=file1$normal_bayes_pvalue,tumor_bayes_beta0=file1$tumor_bayes_beta0,tumor_bayes_pvalue=file1$tumor_bayes_pvalue)
  file1$FDR1=p.adjust(file1$normal_bayes_pvalue,method = "BH")
  file1$FDR2=p.adjust(file1$tumor_bayes_pvalue,method = "BH")
  
  fn2=paste0(dir2,group1[i],".bayes_factor.txt")
  file2=read.table(fn2,head=T,sep="\t")
  file2$unitID=paste(file2$chrom,file2$position,file2$ref,file2$var,sep=":")
  file2=data.frame(unitID=file2$unitID,BayesFactor=file2$BayesFactor)
  file=merge(file2,file1,by="unitID")
  file=file[file$FDR1<0.1|file$FDR2<0.1,]
file=file[file$BayesFactor>1,]
file$normal_group="nosig"
  file[file$normal_bayes_beta0>0&file$FDR1<0.1,]$normal_group="up"
  file[file$normal_bayes_beta0<0&file$FDR1<0.1,]$normal_group="down"
  file$tumor_group="nosig"
  file[file$tumor_bayes_beta0>0&file$FDR2<0.1,]$tumor_group="up"
  file[file$tumor_bayes_beta0<0&file$FDR2<0.1,]$tumor_group="down"
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file=file[,-c(4,6,9,10)]
names(file)=c("unitID",paste(group1[i],names(file)[2:6],sep="_"),names(file)[7])
normal_down_tumor_down=file[file$pattern=="normal_down-tumor_down",][,1:6]

normal_up_tumor_nosig=file[file$pattern=="normal_up-tumor_nosig",][,1:6]
normal_up_tumor_up=file[file$pattern=="normal_up-tumor_up",][,1:6]
normal_down_tumor_nosig=file[file$pattern=="normal_down-tumor_nosig",][,1:6]
normal_nosig_tumor_up=file[file$pattern=="normal_nosig-tumor_up",][,1:6]
normal_down_tumor_up=file[file$pattern=="normal_down-tumor_up",][,1:6]
normal_up_tumor_down=file[file$pattern=="normal_up-tumor_down",][,1:6]
normal_down_tumor_down=file[file$pattern=="normal_down-tumor_down",][,1:6]
normal_nosig_tumor_down=file[file$pattern=="normal_nosig-tumor_down",][,1:6]

for(i in 2:6){
fn1=paste0(dir1,group1[i],".bayes_p.txt")
  file1=read.table(fn1,head=T,sep = "\t")
  file1$unitID=paste(file1$chrom,file1$position,file1$ref,file1$var,sep=":")
  file1=data.frame(unitID=file1$unitID,normal_bayes_beta0=file1$normal_bayes_beta0,normal_bayes_pvalue=file1$normal_bayes_pvalue,tumor_bayes_beta0=file1$tumor_bayes_beta0,tumor_bayes_pvalue=file1$tumor_bayes_pvalue)
  file1$FDR1=p.adjust(file1$normal_bayes_pvalue,method = "BH")
  file1$FDR2=p.adjust(file1$tumor_bayes_pvalue,method = "BH")
  
  fn2=paste0(dir2,group1[i],".bayes_factor.txt")
  file2=read.table(fn2,head=T,sep="\t")
  file2$unitID=paste(file2$chrom,file2$position,file2$ref,file2$var,sep=":")
  file2=data.frame(unitID=file2$unitID,BayesFactor=file2$BayesFactor)
  file=merge(file2,file1,by="unitID")
  file=file[file$FDR1<0.1|file$FDR2<0.1,]
file=file[file$BayesFactor>1,]
file$normal_group="nosig"
  file[file$normal_bayes_beta0>0&file$FDR1<0.1,]$normal_group="up"
  file[file$normal_bayes_beta0<0&file$FDR1<0.1,]$normal_group="down"
  file$tumor_group="nosig"
  file[file$tumor_bayes_beta0>0&file$FDR2<0.1,]$tumor_group="up"
  file[file$tumor_bayes_beta0<0&file$FDR2<0.1,]$tumor_group="down"
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file=file[,-c(4,6,9,10)]
names(file)=c("unitID",paste(group1[i],names(file)[2:6],sep="_"),names(file)[7])

normal_up_tumor_nosig=merge(normal_up_tumor_nosig,file[file$pattern=="normal_up-tumor_nosig",][,1:6],by="unitID",all=T)
  normal_up_tumor_up=merge(normal_up_tumor_up,file[file$pattern=="normal_up-tumor_up",][,1:6],by="unitID",all=T)
  normal_down_tumor_nosig=merge(normal_down_tumor_nosig,file[file$pattern=="normal_down-tumor_nosig",][,1:6],by="unitID",all=T)
  normal_nosig_tumor_up=merge(normal_nosig_tumor_up,file[file$pattern=="normal_nosig-tumor_up",][,1:6],by="unitID",all=T)
  normal_down_tumor_up=merge(normal_down_tumor_up,file[file$pattern=="normal_down-tumor_up",][,1:6],by="unitID",all=T)
  normal_up_tumor_down=merge(normal_up_tumor_down,file[file$pattern=="normal_up-tumor_down",][,1:6],by="unitID",all=T)
  normal_down_tumor_down=merge(normal_down_tumor_down,file[file$pattern=="normal_down-tumor_down",][,1:6],by="unitID",all=T)
  normal_nosig_tumor_down=merge(normal_nosig_tumor_down,file[file$pattern=="normal_nosig-tumor_down",][,1:6],by="unitID",all=T)
}
normal_up_tumor_nosig$pattern="normal_up_tumor_nosig"
normal_up_tumor_up$pattern="normal_up_tumor_up"
normal_down_tumor_nosig$pattern="normal_down_tumor_nosig"
normal_nosig_tumor_up$pattern="normal_nosig_tumor_up"
normal_down_tumor_up$pattern="normal_down_tumor_up"
normal_up_tumor_down$pattern="normal_up_tumor_down"
normal_down_tumor_down$pattern="normal_down_tumor_down"
normal_nosig_tumor_down$pattern="normal_nosig_tumor_down"

rt=rbind(normal_up_tumor_nosig,normal_up_tumor_up,normal_down_tumor_nosig,normal_nosig_tumor_up,normal_down_tumor_up,normal_up_tumor_down,normal_down_tumor_down,normal_nosig_tumor_down)
test=data.frame(table(rt$pattern))
write.csv(test,"./20201110找到有差异的且具有相同pattern的位点/DC.8pattern.union.statis.csv",quote=F,row.names = F)
###双发和健康
i=7
fn1=paste0(dir1,group1[i],".bayes_p.txt")
  file1=read.table(fn1,head=T,sep = "\t")
  file1$unitID=paste(file1$chrom,file1$position,file1$ref,file1$var,sep=":")
  file1=data.frame(unitID=file1$unitID,normal_bayes_beta0=file1$normal_bayes_beta0,normal_bayes_pvalue=file1$normal_bayes_pvalue,tumor_bayes_beta0=file1$tumor_bayes_beta0,tumor_bayes_pvalue=file1$tumor_bayes_pvalue)
  file1$FDR1=p.adjust(file1$normal_bayes_pvalue,method = "BH")
  file1$FDR2=p.adjust(file1$tumor_bayes_pvalue,method = "BH")
  
  fn2=paste0(dir2,group1[i],".bayes_factor.txt")
  file2=read.table(fn2,head=T,sep="\t")
  file2$unitID=paste(file2$chrom,file2$position,file2$ref,file2$var,sep=":")
  file2=data.frame(unitID=file2$unitID,BayesFactor=file2$BayesFactor)
  file=merge(file2,file1,by="unitID")
  file=file[file$FDR1<0.1|file$FDR2<0.1,]
file=file[file$BayesFactor>1,]
file$normal_group="nosig"
  file[file$normal_bayes_beta0>0&file$FDR1<0.1,]$normal_group="up"
  file[file$normal_bayes_beta0<0&file$FDR1<0.1,]$normal_group="down"
  file$tumor_group="nosig"
  file[file$tumor_bayes_beta0>0&file$FDR2<0.1,]$tumor_group="up"
  file[file$tumor_bayes_beta0<0&file$FDR2<0.1,]$tumor_group="down"
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file=file[,-c(4,6,9,10)]
names(file)=c("unitID",paste(group1[i],names(file)[2:6],sep="_"),names(file)[7])
normal_down_tumor_down=file[file$pattern=="normal_down-tumor_down",][,1:6]
one_is_down=file[file$pattern=="normal_down-tumor_nosig"|file$pattern=="normal_nosig-tumor_down",][,1:6]
onedown_oneup=file[file$pattern=="normal_down-tumor_up"|file$pattern=="normal_up-tumor_down",][,1:6]
one_is_up=file[file$pattern=="normal_nosig-tumor_up"|file$pattern=="normal_up-tumor_nosig",][,1:6]
normal_up_tumor_up=file[file$pattern=="normal_up-tumor_up",][,1:6]


for(i in 8:10){
  fn1=paste0(dir1,group1[i],".bayes_p.txt")
  file1=read.table(fn1,head=T,sep = "\t")
  file1$unitID=paste(file1$chrom,file1$position,file1$ref,file1$var,sep=":")
  file1=data.frame(unitID=file1$unitID,normal_bayes_beta0=file1$normal_bayes_beta0,normal_bayes_pvalue=file1$normal_bayes_pvalue,tumor_bayes_beta0=file1$tumor_bayes_beta0,tumor_bayes_pvalue=file1$tumor_bayes_pvalue)
  file1$FDR1=p.adjust(file1$normal_bayes_pvalue,method = "BH")
  file1$FDR2=p.adjust(file1$tumor_bayes_pvalue,method = "BH")
  
  fn2=paste0(dir2,group1[i],".bayes_factor.txt")
  file2=read.table(fn2,head=T,sep="\t")
  file2$unitID=paste(file2$chrom,file2$position,file2$ref,file2$var,sep=":")
  file2=data.frame(unitID=file2$unitID,BayesFactor=file2$BayesFactor)
  file=merge(file2,file1,by="unitID")
  file=file[file$FDR1<0.1|file$FDR2<0.1,]
file=file[file$BayesFactor>1,]
file$normal_group="nosig"
  file[file$normal_bayes_beta0>0&file$FDR1<0.1,]$normal_group="up"
  file[file$normal_bayes_beta0<0&file$FDR1<0.1,]$normal_group="down"
  file$tumor_group="nosig"
  file[file$tumor_bayes_beta0>0&file$FDR2<0.1,]$tumor_group="up"
  file[file$tumor_bayes_beta0<0&file$FDR2<0.1,]$tumor_group="down"
  file$pattern=paste0("normal_",file$normal_group,"-tumor_",file$tumor_group)
  file=file[,-c(4,6,9,10)]
names(file)=c("unitID",paste(group1[i],names(file)[2:6],sep="_"),names(file)[7])
  normal_down_tumor_down=merge(normal_down_tumor_down,file[file$pattern=="normal_down-tumor_down",][,1:6],by="unitID",all=T)
  one_is_down=merge(one_is_down,file[file$pattern=="normal_down-tumor_nosig"|file$pattern=="normal_nosig-tumor_down",][,1:6],by="unitID",all=T)
  onedown_oneup=merge(onedown_oneup,file[file$pattern=="normal_down-tumor_up"|file$pattern=="normal_up-tumor_down",][,1:6],by="unitID",all=T)
  one_is_up=merge(one_is_up,file[file$pattern=="normal_nosig-tumor_up"|file$pattern=="normal_up-tumor_nosig",][,1:6],by="unitID",all=T)
  normal_up_tumor_up=merge(normal_up_tumor_up,file[file$pattern=="normal_up-tumor_up",][,1:6],by="unitID",all=T)
}
normal_down_tumor_down$pattern2="normal_down_tumor_down"
one_is_down$pattern2="one_is_down"
onedown_oneup$pattern2="onedown_oneup"
one_is_up$pattern2="one_is_up"
normal_up_tumor_up$pattern2="normal_up_tumor_up"
rt=rbind(normal_down_tumor_down,one_is_down,onedown_oneup,one_is_up,normal_up_tumor_up)
test=data.frame(table(rt$pattern2))
write.csv(test,"./20201110找到有差异的且具有相同pattern的位点/CC.5pattern.union.statis.csv",quote=F,row.names = F)

